import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        int[] ns = { 28, 12, 89, 73, 65, 18, 96, 50, 8, 36 };
        // 排序前:
        System.out.println(Arrays.toString(ns));
        for(int i=0 ; i<ns.length-1;i++){
            for(int j=0;j<ns.length-i-1;j++){
                if(ns[j]>ns[j+1]){
                    int tem = ns[j];
                    ns[j]= ns[j+1];
                    ns[j+1] = tem;
                }
            }
        }
        // 排序后:
        System.out.println(Arrays.toString(ns));
        // Arrays.sort(ns);
        // System.out.println(Arrays.toString(ns));

        //倒序
        for(int i=0;i<ns.length-1;i++){
            for(int j= 0;j<ns.length-i-1;j++){
                //交换数值
                if(ns[j]<ns[j+1]){
                    int tep =ns[j];
                    ns[j]=ns[j+1];
                    ns[j+1]= tep;
                }
            }
            
        }
            //降序后
            if(Arrays.toString(ns).equals("[96, 89, 73, 65, 50, 36, 28, 18, 12, 8]")){
                System.out.println("测试成功");
            }else{
                System.out.println("测试失败");
            }
            System.out.println(Arrays.toString(ns));


    }
}
